'use strict';

const Koa = require('koa');
const bodyparser = require('koa-bodyparser');
const web = require('./web');
const templet = require('./templet');
const isProduct = process.env.NODE_ENV === 'production';
const app = new Koa();

if (!isProduct) {
    let staticFiles = require('./static-files');
    app.use(staticFiles('/public', __dirname + '/public'));
}
app.use(bodyparser());

app.use(templet('views', {
    noCache: !isProduct,
    watch: !isProduct
}));
app.use(web());

app.listen(8080);
console.log('Start at http://localhost:8080');
